home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 11573 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.8 KB

  1. Path: erich.triumf.ca!bennett
  2. From: bennett@erich.triumf.ca (P.Bennett)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Converting numbers to strings?
  5. Date: 24 Mar 1996 21:44 PST
  6. Organization: TRIUMF: Tri-University Meson Facility
  7. Distribution: world
  8. Message-ID: <24MAR199621444998@erich.triumf.ca>
  9. References: <4j4agq$85h@mozo.cc.purdue.edu>
  10. NNTP-Posting-Host: ftp.triumf.ca
  11. News-Software: VAX/VMS VNEWS 1.50    
  12.  
  13. In article <4j4agq$85h@mozo.cc.purdue.edu>, jonesbr@roger.ecn.purdue.edu (Brian R. Jones) writes...
  14. >I am pretty familiar with the functions that convert strings into
  15. >numbers, but am totally unfamiliar with the reverse process.  What
  16. >I am looking to do is have a program save several files with the
  17. >same basic file root, but differentiated by a number.  For example
  18. >I have a loop in my code that varies a variable, q, that varies in
  19. >increments of 100.  Each time through the loop, I would like to save
  20. >a data file called:
  21. >        out1q100.dat
  22. >        out1q200.dat
  23. >        out1q300.dat
  24. >        etc.
  25. >It seems that if I can simply convert the floating point variable, q,
  26. >to a string, I could use strcat to add it to the basic filename root,
  27.  
  28. I would make the variable q an int, not a float, since you apparently don't
  29. want a decimal part in the file name...
  30.  
  31. Are you familiar with the printf() and fprintf() functions? Look at their close
  32. relative sprintf().  (you may also find sscanf() useful when converting from
  33. strings to numbers...)
  34.  
  35.  
  36. Peter Bennett VE7CEI                | Vessels shall be deemed to be in sight
  37. Internet: bennett@triumf.ca         | of one another only when one can be
  38. Packet: ve7cei@ve7kit.#vanc.bc.ca   | observed visually from the other
  39. TRIUMF, Vancouver, B.C., Canada     |                          ColRegs 3(k)
  40. GPS and NMEA info and programs: ftp://sundae.triumf.ca/pub/peter/index.html
  41. or: ftp://ftp-i2.informatik.rwth-aachen.de/pub/arnd/GPS/peter/index.html
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.